package com.wing.order.service;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wing.order.dao.OrderDistributionLabelDao;
import com.wing.order.model.entity.OrderDistributionLabel;
import com.wing.order.model.request.OrderDistributionLabelForm;
import com.wing.order.model.response.OrderDistributionLabelVO;
import com.wing.order.model.response.ScanDeliveryVo;
import com.wing.order.model.response.ScanPickUpVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 配货明细-ServiceImpl
 *
 * @author
 */
@Service
@Slf4j
public class OrderDistributionLabelServiceImpl extends ServiceImpl<OrderDistributionLabelDao, OrderDistributionLabel> implements OrderDistributionLabelService {

    @Override
    public int add(OrderDistributionLabelForm orderDistributionLabelForm) {

        //校验

        OrderDistributionLabel orderDistributionLabel =new OrderDistributionLabel();
        CopyOptions copyOptions = CopyOptions.create()
        .setEditable(OrderDistributionLabel.class)
        .setIgnoreError(true)
        .setIgnoreNullValue(true);
        BeanUtil.copyProperties(orderDistributionLabelForm, orderDistributionLabel, copyOptions);

        return baseMapper.insert(orderDistributionLabel);
    }

    @Override
    public List<OrderDistributionLabelVO> list4app(Map<String, Object> params) {
        return baseMapper.list4app(params);
    }

    @Override
    public Page<OrderDistributionLabelVO> pageList4app(Page page, Map<String, Object> params) {
        List<OrderDistributionLabelVO> list = baseMapper.list4app(page, params);
        page.setRecords(list);
        return page;
    }

    @Override
    public OrderDistributionLabelVO get4appById(Long id) {
        return baseMapper.get4appById(id);
    }

    @Override
    public List<ScanPickUpVo>  getPickUpFinsh(String deliveryOrderCode) {
        return baseMapper.getPickUpFinsh(deliveryOrderCode);
    }
}
